from torch import nn
class Model(nn.Module):
    def __init__(self, input_channels=1, num_classes=5):
        super(Model, self).__init__()

        # 定义卷积层和池化层
        self.conv1 = nn.Conv1d(input_channels, 32, kernel_size=3, padding=1)
        self.pool1 = nn.MaxPool1d(kernel_size=2)
        self.conv2 = nn.Conv1d(32, 64, kernel_size=3, padding=1)
        self.pool2 = nn.MaxPool1d(kernel_size=2)

        # 定义全连接层
        self.fc1 = nn.Linear(64*65, 32)
        self.fc2 = nn.Linear(32, num_classes)

    def forward(self, x ,n=1):
        # 前向传播
        out = self.conv1(x)
        out = nn.ReLU()(out)
        out = self.pool1(out)
        out = self.conv2(out)
        out = nn.ReLU()(out)
        out = self.pool2(out)
        out = out.view(n,-1)  # 展平卷积层的输出
        out = self.fc1(out)
        out = nn.ReLU()(out)
        out = self.fc2(out)
        out = out.view(n,1,-1)
        return out
